//
//  requestStation.m
//  Runone
//
//  Created by runone01 on 16/8/6.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "requestStation.h"
#import "BCNetAPIClient.h"
#import "MJExtension.h"
#import "Define.h"
@implementation requestStation
static requestStation *station=nil;
+(requestStation *)shareRequestStation
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        station = [[requestStation alloc] init];
    });
    
    return station;
    
}

-(NSString *)stringADD:(NSString *)def
{
    
    NSString *beginstr=@"[{\"key\":\"TollStationUID\",\"value\":\"";
    NSString *str=def;
    NSString *endstr=@"\"}]";
    NSString *temp=[beginstr stringByAppendingString:str];
    NSString *compStr=[temp stringByAppendingString:endstr];
    
    return compStr;
}

//def是后台需要拼接的参数 block是回调的实体
-(void)RequestJsonString:(NSString *)def andCallBack:(callBackMutablArray)block
{
    NSString *jsonString = def;
    NSDictionary *dic=[[NSDictionary alloc] init];
    dic=@{@"methodName":@"GetTollStationDetailInfo",@"updatedtime":@"",@"systemcode":@"GuangleHighway",@"datavalue":jsonString};
    
//    [[BCNetAPIClient sharedJsonClient] requestJsonDataWithPath:GetStationDetaliURL withParams:dic withMethodType:1 andBlock:^(id data, NSError *error) {
//        if (data) {
//            NSArray *temp=[data objectForKey:@"DataValue"];
//            self.tempArr=[[NSMutableArray alloc] init];
//            NSDictionary *dic=[temp mj_JSONObject];
//            //for (NSDictionary *dic in arr) {
//            self.station=[[StationModel alloc] init];
//            self.station.DutyEndTime=dic[@"DutyEndTime"];
//            self.station.DutyPersonName=dic[@"DutyPersonName"];
//            self.station.DutyPersonUID=dic[@"DutyPersonUID"];
//            self.station.DutyStartTime=dic[@"DutyStartTime"];
//            self.station.ETCEntranceCount=dic[@"DutyEndTime"];
//            self.station.ETCExitCount=dic[@"ETCEntranceCount"];
//            self.station.EntranceLaneCount=dic[@"EntranceLaneCount"];
//            self.station.ExitLaneCount=dic[@"ExitLaneCount"];
//            self.station.IsLeader=dic[@"IsLeader"];
//            self.station.IsTwoWayPay=dic[@"IsTwoWayPay"];
//            self.station.Latitude=dic[@"Latitude"];
//            self.station.Longitude=dic[@"Longitude"];
//            self.station.MobilePhone=dic[@"MobilePhone"];
//            self.station.PileNo=dic[@"PileNo"];
//  //          self.station.SystemCode=dic[@"SystemCode"];
//            self.station.SystemUID=dic[@"SystemUID"];
//            self.station.TollStationName=dic[@"TollStationName"];
//            self.station.TollStationUID=dic[@"TollStationUID"];
//            self.station.VideoSetting=dic[@"VideoSetting"];
//           // [self.tempArr addObject:self.station];
//            block(self.station);
//        }
//        
//        else
//        {
//            NSLog(@"++%@",error);
//        }
//    }];
}


-(NSString *)getTime
{
    NSDate * mydate = [NSDate date];
    
    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    
    NSDateComponents *comps = nil;
    
    comps = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitMonth fromDate:mydate];
    
    NSDateComponents *adcomps = [[NSDateComponents alloc] init];
    
    [adcomps setYear:0];
    
    [adcomps setMonth:-2];
    
    [adcomps setDay:0];
    NSDate *newdate = [calendar dateByAddingComponents:adcomps toDate:mydate options:0];
    NSString *beforDate = [dateFormatter stringFromDate:newdate];
    return beforDate;
}

@end
